package com.qf.smsplatform.controller;
/*2021/10/26*/

import com.qf.smsplatform.dto.R;
import com.qf.smsplatform.dto.UserDto;
import com.qf.smsplatform.pojo.TAdminUser;
import com.qf.smsplatform.service.TAdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @YuTao
 *
 */
//@RestController
//@RequestMapping("/user")
public class UserController {

    private TAdminUserService tAdminUserService;
//    @Autowired
    public void settAdminUserService(TAdminUserService tAdminUserService) {
        this.tAdminUserService = tAdminUserService;
    }
//    @PostMapping("/login")
    public R loginTAdminUser(UserDto userDto, HttpSession session){
        //将前端传递过来的数据交给业务层进行判断
        TAdminUser user1 = tAdminUserService.login(userDto);
        //最终查询到结果说明无误，存session中保存登录状态
        session.setAttribute("user", user1);
        return R.setOk();//向前端响应数据
    }
}
